import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    artistData:{
      master:"",
    },
    randomData:{

    },
    collectionData:{

    },
    searchData:{

    },
    songListData:{

    },
    loginData:{
      login:false,
    },
    likeData:{

    }
  },
  getters:{
    getArtistData(state){
      return state.artistData;
    },
    getCollectionData(state){
      return state.collectionData;
    },
    getRandomData(state){
      return state.randomData;
    },
    getSearchData(state){
      return state.searchData;
    },
    getSongListData(state){
      return state.songListData;
    },
    getLoginData(state){
      return state.loginData;
    },
    getLikeData(state){
      return state.likeData;
    }
  },
  mutations: {
    setArtistData(state,payload){
        state.artistData=payload;
    },
    setCollectionData(state,payload){
      state.collectionData=payload;
    },
    setRandomData(state,payload){
      state.randomData=payload;
    },
    setSearchData(state,payload){
      state.searchData=payload;
    },
    setSongListData(state,payload){
      state.songListData=payload;
    },
    setLoginData(state,payload,flag){
      state.loginData=payload;
      state.loginData.login=flag
    },
    setLikeData(state,payload){
      state.likeData=payload;
    }
  },
  actions: {
    setArtistDataAsync(context){
      context.commit('getArtistData');
    },
    setCollectionAsync(context){
      context.commit('getCollectionData');
    },
    setRandomDataAsync(context){
      context.commit('getRandomDate');
    },
    setSearchDataAsync(context){
      context.commit('getSearchData')
    },
    setSongListDataAsync(context){
      context.commit('getSongListData')
    },
    setLoginDataAsync(context){
      context.commit('getLoginData')
    },
    setLikeDataAsync(context){
      context.commit('getLikeData')
    }
  },
  modules: {
  }
})
